package com.ruoyi.web.controller.counter;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.counter.domain.Opdoor;
import com.ruoyi.counter.service.IOpdoorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 柜门记录Controller
 *
 * @author xll
 * @date 2021-07-30
 */
@RestController
@RequestMapping("/counter/opdoor")
public class OpdoorController extends BaseController
{
    @Autowired
    private IOpdoorService opdoorService;

    /**
     * 查询柜门记录列表
     */
    @PreAuthorize("@ss.hasPermi('counter:opdoor:list')")
    @GetMapping("/list")
    public TableDataInfo list(Opdoor opdoor)
    {
        startPage();
        List<Opdoor> list = opdoorService.selectOpdoorList(opdoor);
        return getDataTable(list);
    }

    /**
     * 导出柜门记录列表
     */
    @PreAuthorize("@ss.hasPermi('counter:opdoor:export')")
    @Log(title = "柜门记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Opdoor opdoor)
    {
        List<Opdoor> list = opdoorService.selectOpdoorList(opdoor);
        ExcelUtil<Opdoor> util = new ExcelUtil<Opdoor>(Opdoor.class);
        return util.exportExcel(list, "柜门记录数据");
    }

    /**
     * 获取柜门记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('counter:opdoor:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(opdoorService.selectOpdoorById(id));
    }

    /**
     * 新增柜门记录
     */
    @PreAuthorize("@ss.hasPermi('counter:opdoor:add')")
    @Log(title = "柜门记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Opdoor opdoor)
    {
        return toAjax(opdoorService.insertOpdoor(opdoor));
    }

    /**
     * 修改柜门记录
     */
    @PreAuthorize("@ss.hasPermi('counter:opdoor:edit')")
    @Log(title = "柜门记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Opdoor opdoor)
    {
        return toAjax(opdoorService.updateOpdoor(opdoor));
    }

    /**
     * 删除柜门记录
     */
    @PreAuthorize("@ss.hasPermi('counter:opdoor:remove')")
    @Log(title = "柜门记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(opdoorService.deleteOpdoorByIds(ids));
    }
}
